#ifndef COMPASS_H
#define COMPASS_H
/**
 * Created by Samuel Brucksch
 *
 * Compass code taken from http://bluelemonlabs.blogspot.de/2013/08/arduino-simple-compass-with-hmc5883l.html
 * and adapted by Samuel Brucksch
 */
#include <inttypes.h>

#define HMC5883L_Address 0x1E
#define ConfigurationRegisterA 0x00
#define ConfigurationRegisterB 0x01
#define ModeRegister 0x02
#define DataRegisterBegin 0x03
#define Measurement_Continuous 0x00
#define Measurement_Single 0x01

struct MagnetometerScaled
{
  float XAxis;
  float YAxis;
};

struct MagnetometerRaw
{
  int XAxis;
  int YAxis;
};

//MagnetometerScaled readScaledAxis();
MagnetometerRaw readRawAxis();
void initCompass();
int  getHeading();
void compassMaxMin(int xRaw, int yRaw);
void calcScaleFactor_Offset();
void writeCalibration();
void readCalibration();
void startCompassCalibration(void);

#endif

